Skip to content

Prevent Caliper events from dying on problem-group pseudo source files#3058

Merged
Alex-Jordan merged 1 commit into
openwebwork:WeBWorK-2.21from
ubc:upstream-caliper-group-source-guard
Jul 14, 2026
Merged

Prevent Caliper events from dying on problem-group pseudo source files#3058
Alex-Jordan merged 1 commit into
openwebwork:WeBWorK-2.21from
ubc:upstream-caliper-group-source-guard

Conversation

@xcompass

Copy link
Copy Markdown
Member

Summary

Prevent Caliper events from dying on problem-group pseudo source files.

Problems selected from a problem group carry the pseudo source file group:problemGroupName (see WeBWorK::Utils::Instructor::assignProblemToUserSetVersion), which is not a real file under the course templates directory. Caliper::Entity::problem unconditionally passed that path to WeBWorK::Utils::Tags->new, whose open ... or die kills the request. As a result, any Caliper event that embeds the problem entity — for example an answer-submission event in a gateway quiz built from problem groups — crashed server side whenever Caliper is enabled.

This change guards the tag-parsing block in sub problem so it is skipped for group: pseudo source files. For those problems the entity payload now reports keywords => [] and tags => undef. Real problem files are unaffected: WeBWorK::Utils::Tags initializes {keywords} to [] for every real .pg file it parses, so keywords is always an arrayref, and the keyword trimming and unblessed tag hash are built exactly as before.

Note that sub problem_user intentionally keeps the unguarded tag parsing: user problems for versioned (gateway) sets are assigned a concrete source file selected out of the group at set-version creation time, so a merged user problem never carries the group: pseudo path.

Testing

  • Exercised Caliper::Entity::problem with the dependency surface stubbed (WeBWorK::DB, Caliper::ResourceIri, and a WeBWorK::Utils::Tags stub reproducing the real open ... or die behavior):
    • Before this change, a problem with source file group:myGroup dies with cannot open .../group:myGroup: No such file or directory; after this change it returns a payload with keywords => [], extensions.tags => undef, and extensions.source_file passed through.
    • A real .pg source file produces an identical payload before and after the change (keywords trimmed of quotes/whitespace, unblessed tags hash populated).
    • A missing real (non-group:) source file still dies as before; this change does not swallow genuine errors.
  • perl -c lib/Caliper/Entity.pm passes (with dependency stubs, since a full course environment is not available in the check environment).
  • perltidy (Perl::Tidy 20260204, matching check-formats.yml) with the repo .perltidyrc produces no changes.

Dependencies

Depends on #3050 (this branch is based on it, since #3050 already touches the same region of lib/Caliper/Entity.pm with the Caliper::ResourceIri package rename and the showHintsAfter() fix).

Problems selected from a problem group have the pseudo source file
"group:problemGroupName" (see
WeBWorK::Utils::Instructor::assignProblemToUserSetVersion), which is not
a real file under the course templates directory.  Caliper::Entity::problem
unconditionally passed that path to WeBWorK::Utils::Tags->new, which dies
when it cannot open the file, so any Caliper event embedding the problem
entity (e.g. answer submission in a gateway quiz that uses problem groups)
crashed server side.

Skip tag parsing for "group:" pseudo source files instead.  For those
problems the entity now reports keywords => [] and tags => undef.  Real
problem files are unaffected: their keywords and unblessed tags are built
exactly as before.

@drgrice1 drgrice1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is okay for now.

You should be forewarned that I have entirely rewritten the Caliper code. There are lots of issues with it. One is that its code is all over in the webwork2 code base, and it is something that is rarely used, and it carries overhead even if not used. My rewrite moves it into a plugin that will not even be used unless the server administrator enables it. The code is generally a kludge as well. It is poorly written and is a mess. (Things like you did even in your changes such as adding unnecessary empty parenthesis after object method calls, and quoting hash keys.) I have completely cleaned it up and fixed other issues with it.

I have integrated this change into my rewrite. I will most likely wait until the next release for my rewrite.

@xcompass

Copy link
Copy Markdown
Member Author

We have been using this in our instance for the past year. Plugin sound a great idea. Looking forward to your rewrite!

@Alex-Jordan Alex-Jordan merged commit ffcda3e into openwebwork:WeBWorK-2.21 Jul 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants